class Solution:
    def minPatches(self, nums: List[int], n: int) -> int:
        x,index=1,0
        count=0
        while x<n+1:
            if index<len(nums) and nums[index]<=x:
                x+=nums[index]
                index+=1
            else:
                count+=1
                x*=2
        return count

'''

'''